

function say() {
    alert("LC:589. N 叉树的前序遍历");
}
say();

/**
 * // Definition for a Node.
 * function Node(val, children) {
 *    this.val = val;
 *    this.children = children;
 * };
 */

/**
 * @param {Node} root
 * @return {number[]}
 */
var preorder = function(root) {
    //4:32 - 47

    var arr = []
    recursive(root, arr)

    return arr
};


function recursive(root, arr){
    if(root){
        arr.push(root.val)
        var children = root.children
        for(var i = 0; i < children.length; i++){
            recursive(children[i], arr)
        }
    }
}
